clear all
set more off


import spss "data/raw/ATP W39.sav", clear


** race indicators
gen black = 1 if F_RACECMB == 2
replace black = 0 if F_RACECMB != 2
replace black = . if F_RACECMB == 99


gen asian = 1 if F_RACECMB == 3
replace asian = 0 if F_RACECMB != 3
replace asian = . if F_RACECMB == 99


gen white = 1 if F_RACECMB == 1
replace white = 0 if F_RACECMB != 1
replace white = . if F_RACECMB == 99


** age bins
gen age = 23.5 if F_AGECAT == 1
replace age = 39.5 if F_AGECAT == 2
replace age = 57 if F_AGECAT == 3
replace age = 65 if F_AGECAT == 4
replace age = . if F_AGECAT == 99


** hispanic 
gen hisp = 1 if F_HISP == 1
replace hisp = 0 if F_HISP == 2
replace hisp = . if F_HISP == 99

 
** male
gen male = 1 if F_SEX == 1
replace male = 0 if F_SEX == 2
replace male = . if F_SEX == 99


** political party
gen political_party = F_PARTY_FINAL
replace political_party = . if F_PARTY_FINAL == 99

** political lean
gen political_lean = F_PARTYLN_FINAL
replace political_lean = . if F_PARTYLN_FINAL == 99

** political final
gen political_party_lean = F_PARTYSUM_FINAL 
replace political_party_lean =. if F_PARTYSUM_FINAL == 99

 
** education

gen highschool_more = 1 if F_EDUCCAT2 > 1
replace highschool_more = 0 if F_EDUCCAT2 == 1
replace highschool_more = . if F_EDUCCAT2 == 99

gen bachelor_more = 1 if F_EDUCCAT == 1
replace bachelor_more = 0 if F_EDUCCAT > 1
replace bachelor_more = . if F_EDUCCAT == 99


ren WEIGHT_W39_FINAL weight

ren highschool_more hs
ren bachelor_more bachelors

keep QKEY black asian age hisp male white political_party political_lean political_party_lean hs bachelors weight

save "data/working/pew.dta",replace






